package com.teach.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;

@Configuration
@Slf4j
public class BeanConfig {

  @Autowired
  private ConfigProperties config;

  @Bean
  public Snowflake snowflake3(){
    log.info("创建雪花数bean:{},{}",config.getWorkerId(),config.getDataCenterId());
    return IdUtil.getSnowflake(config.getWorkerId(),config.getDataCenterId());
  }
  
  @Bean
  public UUID uuid(){
    return UUID.fastUUID();
  }

  @Bean("自定义beanId")
  @Primary
  public Snowflake snowflake(){
    return IdUtil.getSnowflake();
  }
  @Bean
  public Snowflake snowflake2(){
    return IdUtil.getSnowflake(1,1);
  }
}
